using System;
using System.Collections.Generic;
using System.Text;

namespace TST.SharePoint.Shared
{
    /// <summary>
    /// A FieldReference is used to store a references to a specific Field object. Used by
    /// the ContentByType webpart to store which fields to display.
    /// Apart from the references, it also saves the custom configuration the these
    /// fields.
    /// </summary>
    [Serializable()]
    public class FieldReference : IIdentifiable<string>
    {
        private string _id;
        private string _linkFieldId;

        /// <summary>
        /// Constructor.
        /// </summary>
        public FieldReference()
        {
        }

        /// <summary>
        /// Contructor. Takes a Field as parameter and configures the Reference to that
        /// Field.
        /// </summary>
        /// <param name="field">The field object to be referenced.</param>
        public FieldReference(Field field)
        {
            if (field != null)
            {
                _id = field.Id;
                _linkFieldId = field.LinkFieldId;
            }
        }

        /// <summary>
        /// Get or set the ID for the LinkField.
        /// </summary>
        public string LinkFieldId
        {
            get { return _linkFieldId; }
            set { _linkFieldId = value; }
        }

        private string _displayName;
        public string DisplayName
        {
            get { return _displayName; }
            set
            {
                _displayName = value;
            }
        }

        private bool _openInNewWindow;
        public bool OpenInNewWindow
        {
            get { return _openInNewWindow; }
            set
            {
                _openInNewWindow = value;
            }
        }

        #region IIdentifiable<string> Members

        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        #endregion
    }
}
